Optimal. Leaf size=202 \[ -\frac{\sin (c+d x) \left (a^2 (-(A-C))-a b B+2 A b^2\right )}{a^2 d \left (a^2-b^2\right )}+\frac{2 \left (3 a^2 A b^2-2 a^3 b B+a^4 C+a b^3 B-2 A b^4\right ) \tanh ^{-1}\left (\frac{\sqrt{a-b} \tan \left (\frac{1}{2} (c+d x)\right )}{\sqrt{a+b}}\right )}{a^3 d (a-b)^{3/2} (a+b)^{3/2}}+\frac{\sin (c+d x) \left (A b^2-a (b B-a C)\right )}{a d \left (a^2-b^2\right ) (a+b \sec (c+d x))}-\frac{x (2 A b-a B)}{a^3} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.644187, antiderivative size = 202, normalized size of antiderivative = 1., number of steps used = 6, number of rules used = 6, integrand size = 39, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.154, Rules used = {4100, 4104, 3919, 3831, 2659, 208} \[ -\frac{\sin (c+d x) \left (a^2 (-(A-C))-a b B+2 A b^2\right )}{a^2 d \left (a^2-b^2\right )}+\frac{2 \left (3 a^2 A b^2-2 a^3 b B+a^4 C+a b^3 B-2 A b^4\right ) \tanh ^{-1}\left (\frac{\sqrt{a-b} \tan \left (\frac{1}{2} (c+d x)\right )}{\sqrt{a+b}}\right )}{a^3 d (a-b)^{3/2} (a+b)^{3/2}}+\frac{\sin (c+d x) \left (A b^2-a (b B-a C)\right )}{a d \left (a^2-b^2\right ) (a+b \sec (c+d x))}-\frac{x (2 A b-a B)}{a^3} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 4100
Rule 4104
Rule 3919
Rule 3831
Rule 2659
Rule 208
Rubi steps
\begin{align*} \int \frac{\cos (c+d x) \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right )}{(a+b \sec (c+d x))^2} \, dx &=\frac{\left (A b^2-a (b B-a C)\right ) \sin (c+d x)}{a \left (a^2-b^2\right ) d (a+b \sec (c+d x))}-\frac{\int \frac{\cos (c+d x) \left (2 A b^2-a b B-a^2 (A-C)+a (A b-a B+b C) \sec (c+d x)-\left (A b^2-a (b B-a C)\right ) \sec ^2(c+d x)\right )}{a+b \sec (c+d x)} \, dx}{a \left (a^2-b^2\right )}\\ &=-\frac{\left (2 A b^2-a b B-a^2 (A-C)\right ) \sin (c+d x)}{a^2 \left (a^2-b^2\right ) d}+\frac{\left (A b^2-a (b B-a C)\right ) \sin (c+d x)}{a \left (a^2-b^2\right ) d (a+b \sec (c+d x))}+\frac{\int \frac{-\left (a^2-b^2\right ) (2 A b-a B)+a \left (A b^2-a (b B-a C)\right ) \sec (c+d x)}{a+b \sec (c+d x)} \, dx}{a^2 \left (a^2-b^2\right )}\\ &=-\frac{(2 A b-a B) x}{a^3}-\frac{\left (2 A b^2-a b B-a^2 (A-C)\right ) \sin (c+d x)}{a^2 \left (a^2-b^2\right ) d}+\frac{\left (A b^2-a (b B-a C)\right ) \sin (c+d x)}{a \left (a^2-b^2\right ) d (a+b \sec (c+d x))}+\frac{\left (3 a^2 A b^2-2 A b^4-2 a^3 b B+a b^3 B+a^4 C\right ) \int \frac{\sec (c+d x)}{a+b \sec (c+d x)} \, dx}{a^3 \left (a^2-b^2\right )}\\ &=-\frac{(2 A b-a B) x}{a^3}-\frac{\left (2 A b^2-a b B-a^2 (A-C)\right ) \sin (c+d x)}{a^2 \left (a^2-b^2\right ) d}+\frac{\left (A b^2-a (b B-a C)\right ) \sin (c+d x)}{a \left (a^2-b^2\right ) d (a+b \sec (c+d x))}+\frac{\left (3 a^2 A b^2-2 A b^4-2 a^3 b B+a b^3 B+a^4 C\right ) \int \frac{1}{1+\frac{a \cos (c+d x)}{b}} \, dx}{a^3 b \left (a^2-b^2\right )}\\ &=-\frac{(2 A b-a B) x}{a^3}-\frac{\left (2 A b^2-a b B-a^2 (A-C)\right ) \sin (c+d x)}{a^2 \left (a^2-b^2\right ) d}+\frac{\left (A b^2-a (b B-a C)\right ) \sin (c+d x)}{a \left (a^2-b^2\right ) d (a+b \sec (c+d x))}+\frac{\left (2 \left (3 a^2 A b^2-2 A b^4-2 a^3 b B+a b^3 B+a^4 C\right )\right ) \operatorname{Subst}\left (\int \frac{1}{1+\frac{a}{b}+\left (1-\frac{a}{b}\right ) x^2} \, dx,x,\tan \left (\frac{1}{2} (c+d x)\right )\right )}{a^3 b \left (a^2-b^2\right ) d}\\ &=-\frac{(2 A b-a B) x}{a^3}+\frac{2 \left (3 a^2 A b^2-2 A b^4-2 a^3 b B+a b^3 B+a^4 C\right ) \tanh ^{-1}\left (\frac{\sqrt{a-b} \tan \left (\frac{1}{2} (c+d x)\right )}{\sqrt{a+b}}\right )}{a^3 (a-b)^{3/2} (a+b)^{3/2} d}-\frac{\left (2 A b^2-a b B-a^2 (A-C)\right ) \sin (c+d x)}{a^2 \left (a^2-b^2\right ) d}+\frac{\left (A b^2-a (b B-a C)\right ) \sin (c+d x)}{a \left (a^2-b^2\right ) d (a+b \sec (c+d x))}\\ \end{align*}
Mathematica [A] time = 0.955774, size = 160, normalized size = 0.79 \[ \frac{-\frac{2 \left (3 a^2 A b^2-2 a^3 b B+a^4 C+a b^3 B-2 A b^4\right ) \tanh ^{-1}\left (\frac{(b-a) \tan \left (\frac{1}{2} (c+d x)\right )}{\sqrt{a^2-b^2}}\right )}{\left (a^2-b^2\right )^{3/2}}-\frac{a b \sin (c+d x) \left (a (a C-b B)+A b^2\right )}{(a-b) (a+b) (a \cos (c+d x)+b)}+(c+d x) (a B-2 A b)+a A \sin (c+d x)}{a^3 d} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [B] time = 0.131, size = 573, normalized size = 2.8 \begin{align*} \text{result too large to display} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] time = 0.726212, size = 1796, normalized size = 8.89 \begin{align*} \text{result too large to display} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F] time = 0., size = 0, normalized size = 0. \begin{align*} \int \frac{\left (A + B \sec{\left (c + d x \right )} + C \sec ^{2}{\left (c + d x \right )}\right ) \cos{\left (c + d x \right )}}{\left (a + b \sec{\left (c + d x \right )}\right )^{2}}\, dx \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] time = 1.29528, size = 551, normalized size = 2.73 \begin{align*} \frac{\frac{2 \,{\left (C a^{4} - 2 \, B a^{3} b + 3 \, A a^{2} b^{2} + B a b^{3} - 2 \, A b^{4}\right )}{\left (\pi \left \lfloor \frac{d x + c}{2 \, \pi } + \frac{1}{2} \right \rfloor \mathrm{sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac{a \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right ) - b \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right )}{\sqrt{-a^{2} + b^{2}}}\right )\right )}}{{\left (a^{5} - a^{3} b^{2}\right )} \sqrt{-a^{2} + b^{2}}} + \frac{2 \,{\left (A a^{3} \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right )^{3} - A a^{2} b \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right )^{3} + C a^{2} b \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right )^{3} - A a b^{2} \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right )^{3} - B a b^{2} \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right )^{3} + 2 \, A b^{3} \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right )^{3} - A a^{3} \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right ) - A a^{2} b \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right ) + C a^{2} b \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right ) + A a b^{2} \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right ) - B a b^{2} \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right ) + 2 \, A b^{3} \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right )\right )}}{{\left (a \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right )^{4} - b \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right )^{4} - 2 \, b \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right )^{2} - a - b\right )}{\left (a^{4} - a^{2} b^{2}\right )}} + \frac{{\left (B a - 2 \, A b\right )}{\left (d x + c\right )}}{a^{3}}}{d} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]